import request from '/@/utils/request';

// ----- 活动列表 -----
// 列表
export const fetchActivityList = (data?: object) => {
	return request({
		url: '/activity/page',
		method: 'post',
		data,
	});
};

// 统计
export const fetchActivityStatic = (data?: object) => {
	return request({
		url: '/activity/count',
		method: 'post',
		data,
	});
};

// 创建活动
export const fetchCreateActivity = (data: any) => {
	return request({
		url: 'activity/create',
		method: 'post',
		data,
	});
};

// 编辑活动
export const fetchUpdateActivity = (data: any) => {
	return request({
		url: 'activity/update',
		method: 'post',
		data,
	});
};

// 删除
export const fetchDelActivity = (params: any) => {
	return request({
		url: '/activity/delete',
		method: 'get',
		params,
	});
};

// 审核
export const fetchInviteAudit = (data?: object) => {
	return request({
		url: '/activity/audit',
		method: 'post',
		data,
	});
};

// 详情
export const fetchActivityDetail = (params: any) => {
	return request({
		url: '/activity/detail',
		method: 'get',
		params,
	});
};

// 预览
export const fetchQrCode = (data: any) => {
	return request({
		url: '/activity/qrCode',
		method: 'post',
		data,
	});
};

// ----- 邀请 -----
// 邀请列表
export const fetchInviteList = (data?: object) => {
	return request({
		url: '/activity/invite/page',
		method: 'post',
		data,
	});
};
// 新增邀请
export const fetchCreateInvite = (data: any) => {
	return request({
		url: '/activity/invite/create',
		method: 'post',
		data,
	});
};

// 删除邀请
export const fetchDelInvite = (data?: object) => {
	return request({
		url: '/activity/invite/delete',
		method: 'post',
		data,
	});
};

// 导入邀请
export const fetchImportInvite = (data: any) => {
	return request({
		url: `/activity/invite/import?activityId=${data.get('activityId')}`,
		method: 'post',
		headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
		data,
	});
};

// 下载邀请
export const fetchDownInviteTemp = (params: any) => {
	return request({
		url: '/template/活动邀请导入模板.xlsx',
		method: 'get',
		responseType: 'blob',
		params,
	});
};

// 短信邀请
export const fetchSendMessage = (data?: object) => {
	return request({
		url: '/activity/invite/exec',
		method: 'post',
		data,
	});
};

// 活动数据
export const fetchInviteDataList = (data?: object) => {
	return request({
		url: '/activity/data/page',
		method: 'post',
		data,
	});
};

// 导出活动数据
export const fetchExportInviteData = (data?: object) => {
	return request({
		url: '/activity/data/export',
		method: 'post',
		responseType: 'blob',
		data,
	});
};

// 活动数据审核
export const fetchAuditInviteData = (data?: object) => {
	return request({
		url: '/activity/data/audit',
		method: 'post',
		data,
	});
};

// 活动数据核销
export const fetchSettleInviteData = (params?: object) => {
	return request({
		url: '/activity/data/settle',
		method: 'get',
		params,
	});
};
